package com.tang.mybatis.controller;

import com.tang.mybatis.domain.User;
import com.tang.mybatis.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Tang
 * @classname UserController
 * @description [  ]
 * @date 2021/11/21 19:17
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    UserService userService;

    @GetMapping("/get")
    public User getUser(String id) {
        return userService.getById(id);
    }

    @GetMapping("/findAll")
    public List<User> findAll() {
        return userService.findAll();
    }

    @GetMapping("/save")
    public User getUser(@RequestBody User user) {
        userService.save(user);
        return user;
    }


    @PostMapping("/update")
    public int updateUser(@RequestBody User user) {
        userService.updateUser(user);
        return 0;
    }


}